import io from 'socket.io-client';

export const connectSocket = () => {
    const env = process.env.NODE_ENV;
    const socketUrl = env === 'production' 
        ? `${window.location.origin}` // 使用当前浏览器地址
        : 'http://119.253.65.194:3001'; // 测试环境
    window.socket = io(socketUrl);
    return window.socket;
};

export const getSocket = () => {
    return window.socket;
};
export const disconnectSocket = () => {
    if (window.socket) {
        window.socket.disconnect();
        window.socket = null;
    }
};
    